var num = JSON.parse(num);
for (var a = 0; a < num.length; a++) {
    for (var b = 0; b < num[a].length; b++) {
        //投票人数
        var result;
        result = num[a][b]['COUNT(股份数量)'];
        $('tbody tr').eq(a).children("td").eq(3*b).text(result);
    }
}

var arr = JSON.parse(data);
for (var i = 0; i < arr.length; i++) {
    console.log(arr[i])
    var ands = 0;
    //一个议案的所有股份的和
    for (var c = 0; c < arr[i].length; c++) {
        var result;
        result = arr[i][c]['SUM(股份数量)'] == null ? 0 : arr[i][c]['SUM(股份数量)'];
        ands += result;
    }
    var zonghe = ands/10000;
    $('tbody tr:last-child').children("td").eq(0).text(zonghe.toFixed(2)+"万");
    console.log("第"+(i+1)+"个议案的总股份数：",ands);
    for (var j = 0; j < arr[i].length; j++) {
        //投票数量
        var result1;
        result1 = arr[i][j]['SUM(股份数量)'] == null ? 0 : arr[i][j]['SUM(股份数量)'];
        var shuliang = result1/10000;
        $('tbody tr').eq(i).children("td").eq(3*j+1).text(shuliang.toFixed(2));
        //投票比率
        result1 = ands == 0 ? 0 : result1/ands*100;
        var bilv = result1.toFixed(2)+"%";
        $('tbody tr').eq(i).children("td").eq(3*j+2).text(bilv);
    }
}


// function exportexcel(){
//     $("#table1").table2excel({
//         exclude: ".noExl",
//         name: "Excel Document Name",
//         filename: "股东投票",
//         exclude_img: true,
//         exclude_links: true,
//         exclude_inputs: true
//     });
// }

//从table中导出excel表
function method4(tableid){

    var curTbl = document.getElementById(tableid);
    var oXL;
    try{
        oXL = new ActiveXObject("Excel.Application"); //创建AX对象excel
    }catch(e){
        alert("无法启动Excel!\n\n如果您确信您的电脑中已经安装了Excel，"+"那么请调整IE的安全级别。\n\n具体操作：\n\n"+"工具 → Internet选项 → 安全 → 自定义级别 → 对未标记为安全的ActiveX进行初始化和脚本运行 → 启用");
        return false;
    }
    var oWB = oXL.Workbooks.Add(); //获取workbook对象
    var oSheet = oWB.ActiveSheet;//激活当前sheet
    var sel = document.body.createTextRange();
    sel.moveToElementText(curTbl); //把表格中的内容移到TextRange中
    sel.select(); //全选TextRange中内容
    sel.execCommand("Copy");//复制TextRange中内容
    oSheet.Paste();//粘贴到活动的EXCEL中
    oXL.Visible = true; //设置excel可见属性
    var fname = oXL.Application.GetSaveAsFilename("股东投票结果表.xls", "Excel Spreadsheets (*.xls), *.xls");
    oWB.SaveAs(fname);
    oWB.Close();
    oXL.Quit();
}
